<?php
	
	function QueryForAccBalance($user_id,$platformNo,$post_url){
		/* 请求参数 */
		$user = array();
		$user = get_user_info("*","id = ".$user_id);
		$Sign_data= array();
		$Sign_data['cust_no'] = $user['mobile'];
		$Sign_data['mchnt_cd'] = $platformNo;
		$Sign_data['mchnt_txn_ssn'] = $user['id'].time();//请求流水号
		$Sign_data['mchnt_txn_dt'] = to_date(TIME_UTC,"Ymd");//交易日期 yyyyMMdd

		/* 签名数据 */
		ksort($Sign_data);
		foreach($Sign_data as $k => $v){
			if($k=='mchnt_txn_ssn'){
				$Sign_old.=$v;
			}else{
				$Sign_old.= $v."|";
			}
		}

		$pSign=rsaSign($Sign_old,PRIVATE_KEY_PATH);
		//return $Sign_old."---".$pSign;
		//EwGdnA d5Eo10NsfOGwrvevecchZ91hm fiZ8rI5uISQOnkVC4/01lmNbbAS8RSSunAh3OzkMEJuVFGOC i4BP7 qpAYM4Z1m/TWfkzECt8vZId3viP8R4QO0eSaZR5pNqUCWzyXlZtmwvKqmO2TzXtI4SvS7fqwkyxNqmajK2A=
		//5RsNj5FQBQb+S67QiIyAhAaZktpR1VwUlYfzhuUsI4Y5gpwCRsyFSnd3+yYo8IVmPZkX0Jx8MdNehQjtbcgZZrJwWO/xPpA3EeNCwhvGrHDd1ID8fo50bj2+BM9fPtYdod3J/2SvIOCorvwddPxX7NGptQ3h0tmifHZ/5SGPPI0=
		$req = http_build_query($Sign_data)."&signature=".urlencode($pSign);
		$options = array(
			CURLOPT_POST => TRUE,
			CURLOPT_RETURNTRANSFER => TRUE,
			CURLOPT_SSL_VERIFYPEER=>0,
			CURLOPT_SSL_VERIFYHOST=>0,
			CURLOPT_POSTFIELDS =>$req,
		
		); 
	    $ch = curl_init($post_url); 
	    curl_setopt_array($ch,$options); 
	   	$resultStr = curl_exec($ch);
	    curl_close($ch); 

		if (empty($resultStr)){
			$result = array();
			$result['pErrCode'] = 9999;
			$result['pErrMsg'] = '返回出错';
		}else{
			require_once APP_ROOT_PATH.'system/collocation/fuioupay/xml.php';
			$str3ParaInfo = @XML_unserialize($resultStr);
			$str3Req = $str3ParaInfo['ap']['plain'];
			$result = array();
			$result['resp_code'] = $str3Req["resp_code"];
			//$result['mchnt_cd'] = $str3Req["mchnt_cd"];
			//$result['mchnt_txn_ssn'] = $str3Req["mchnt_txn_ssn"];
			$result['results'] =  $str3Req["results"]['result'];
			//$result['Sign_old'] =$Sign_old;
			//$result['pSign'] =$pSign;
			//$result['signature'] =  $str3ParaInfo['ap']['signature'];
			$result['pErrCode'] = $result['resp_code'];
			$result['pBalance'] = $result['results']["ca_balance"]/100;
			$result['pLock'] = $result['results']["cf_balance"]/100;
			$result['pNeedstl'] = 0;
		}
		//$result = json_encode('{"resp_code":"0000","results":{"user_id":"18859145015","ct_balance":"111917","ca_balance":"108017","cf_balance":"3900","cu_balance":"0"},"ct_balance":1119.17,"ca_balance":1080.17,"cf_balance":39,"cu_balance":0}');
		return $result;
	}	
	
?>